/*
 * Copyright (C) 2018 Logos Technology Ltd.
 */

package com.logos.tool.glide;

import android.content.Context;

import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
import com.bumptech.glide.load.engine.cache.LruResourceCache;
import com.bumptech.glide.module.AppGlideModule;

/**
 * @author Young Ken
 */
@GlideModule
public class CustomAppGlideModule extends AppGlideModule {

    /**
     * 通过GlideBuilder设置默认的结构(Engine,BitmapPool ,ArrayPool,MemoryCache等等).
     *
     * @param context Context
     * @param builder GlideBuilder
     */
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {

        int mbyte = 1024 * 1024;
        //重新设置内存限制
        builder.setMemoryCache(new LruResourceCache(6 * mbyte));
        builder.setDiskCache(new InternalCacheDiskCacheFactory(context, 600 * mbyte));

    }

    /**
     * 清单解析的开启
     * 这里不开启，避免添加相同的modules两次
     *
     * @return 不让清单文件加载GlideModule
     */
    @Override
    public boolean isManifestParsingEnabled() {
        return false;
    }
}
